package service;

import dao.StudentDao;
import domain.Student;

import java.util.ArrayList;

public class StudentService {
    private  StudentDao studentDao= new StudentDao();
    public void addStudent(Student student) {
        studentDao.addStudent(student);
    }

    public boolean isExists(String sid) {
        ArrayList<Student> list=studentDao.find();
        for (int i = 0; i < list.size(); i++) {
            Student student = list.get(i);
            if(student.getSid().equals(sid)){
                return true;
            }
        }
        return false;
    }

    public ArrayList<Student> find() {

        return studentDao.find();
    }

    public void delete(String sid) {
        studentDao.delete(sid);
    }

    public void update(String sid, Student student) {
        studentDao.update(sid,student);
    }
}
